#include "stdafx.h"
#include "Fakes/FakeD3D10Device1.h"
#include "Fakes/FakeD3D10BlendState1.h"
#include "Fakes/FakeD3D10Resource.h"

DESCRIPTION_10_1_TEST_SUITE(BlendDescription1)

BOOST_FIXTURE_TEST_CASE(Default, TestBlendDescription1)
{
	BOOST_REQUIRE_EQUAL(FALSE, m_desc.AlphaToCoverageEnable);
	BOOST_REQUIRE_EQUAL(FALSE, m_desc.IndependentBlendEnable);
	rt::D3D10_1::RenderTargetBlendDescription1 const default_;
    for (UINT i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
	{
		D3D10_RENDER_TARGET_BLEND_DESC1 const &desc = m_desc.RenderTarget[i];
		BOOST_REQUIRE_EQUAL(default_.BlendEnable, desc.BlendEnable);
		BOOST_REQUIRE_EQUAL(default_.SrcBlend, desc.SrcBlend);
		BOOST_REQUIRE_EQUAL(default_.DestBlend, desc.DestBlend);
		BOOST_REQUIRE_EQUAL(default_.BlendOp, desc.BlendOp);
		BOOST_REQUIRE_EQUAL(default_.SrcBlendAlpha, desc.SrcBlendAlpha);
		BOOST_REQUIRE_EQUAL(default_.DestBlendAlpha, desc.DestBlendAlpha);
		BOOST_REQUIRE_EQUAL(default_.BlendOpAlpha, desc.BlendOpAlpha);
		BOOST_REQUIRE_EQUAL(default_.RenderTargetWriteMask, desc.RenderTargetWriteMask);
	}
}

#define BLEND_DESCRIPTION_TEST_CASE(type_, name_, value_) \
	DESCRIPTION_10_1_TEST_CASE(type_, name_, value_, BlendDescription1)

BLEND_DESCRIPTION_TEST_CASE(BOOL, AlphaToCoverageEnable, TRUE)
BLEND_DESCRIPTION_TEST_CASE(BOOL, IndependentBlendEnable, TRUE)

BOOST_FIXTURE_TEST_CASE(Create, TestBlendDescription1)
{
	FakeD3D10Device1 device;
	FakeD3D10BlendState1 state;
	device.CreateBlendState1FakeResult = &state;
	device.CreateBlendState1FakeHResult = S_OK;
	ID3D10BlendState1 *result = m_desc.Create(&device);
	BOOST_REQUIRE(device.CreateBlendState1Called);
	BOOST_REQUIRE_EQUAL(&m_desc, device.CreateBlendState1LastDesc);
	BOOST_REQUIRE_EQUAL(&state, result);
}

BOOST_AUTO_TEST_SUITE_END()
